export function chooseImage() {
	return new Promise((r, e) => {
		uni.chooseImage({
			count: 6,
			sizeType: ['original', 'compressed'],
			sourceType: ['camera','album'],
			success: res => {
				r(res)
			},
			fail: (err) => {
				e(err)
			}
		})
	})
}
	//#ifndef H5
export function urlTobase64(url) {
	return new Promise((r, e) => {
		uni.request({
			url: url,
			method: 'GET',
			responseType: 'arraybuffer',
			success: ress => {
				const base64List = [
					{'base64' : wx.arrayBufferToBase64(ress.data)},
					{'showBase64' : 'data:image/jpeg;base64,'}]
				r(base64List)
			},fail: (err) => {
				e(err)
			}
			})
	})
}
	//#endif
export function previewImage(url) {
	return new Promise((r, e) => {
		uni.previewImage({
			urls: url,
			longPressActions: {
				itemList: ['发送给朋友', '保存图片', '收藏'],
				success: function(data) {
					r('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
				},
				fail: function(err) {
					e(err.errMsg);
				}
			}
		});
	})
}
export function getImageInfo(url) {
	return new Promise((r, e) => {
		uni.getImageInfo({
			src: url,
			success: (image) =>{
				r(image.path)
			},fail:(e) =>{
				e(e)
			}
		});
	})
}
